import java.util.Arrays;

/**
 * @author LKQ
 * @date 2022/1/28 11:10
 * @description 排序
 */
public class FormalSolution {
    public static void main(String[] args) {
        FormalSolution solution = new FormalSolution();
        int[][] properties = {{1, 5}, {4, 3}, {10 ,4}, {10, 3}};
        solution.numberOfWeakCharacters(properties);
    }
    public int numberOfWeakCharacters(int[][] properties) {
        Arrays.sort(properties, (o1, o2) -> {
            // 排序规则，攻击力从大到小排序，攻击力相同时防御值从小到大排序
            return o1[0] == o2[0] ? (o1[1] - o2[1]) : (o2[0] - o1[0]);
        });
        int maxDef = 0;
        int ans = 0;
        for (int[] p : properties) {
            if (p[1] < maxDef) {
                ans++;
            } else {
                maxDef = p[1];
            }
        }
        return ans;
    }
}
